using System;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Markup;
using System.Windows.Media;
using Common;
using Common.Enum;

namespace CustomChart
{
	public partial class CurveStyleSettingWindow : Window, IComponentConnector
	{
		public delegate void DelegateOnApplyEvent(object sender, EventArgs e);

		public static readonly DependencyProperty ColorProperty = DependencyProperty.Register("Color", typeof(Color), typeof(CurveStyleSettingWindow), new UIPropertyMetadata(Colors.Black));

		public static readonly DependencyProperty SymbolProperty = DependencyProperty.Register("Symbol", typeof(ESeriesType), typeof(CurveStyleSettingWindow), new UIPropertyMetadata(ESeriesType.None));

		public static readonly DependencyProperty TargetNameProperty = DependencyProperty.Register("TargetName", typeof(string), typeof(CurveStyleSettingWindow), new UIPropertyMetadata(Utility.GetMessage("All")));

		public Color Color
		{
			get
			{
				return (Color)GetValue(ColorProperty);
			}
			set
			{
				SetValue(ColorProperty, value);
			}
		}

		public bool ShowTargets { get; set; }

		public ESeriesType Symbol
		{
			get
			{
				return (ESeriesType)GetValue(SymbolProperty);
			}
			set
			{
				SetValue(SymbolProperty, value);
			}
		}

		public string TargetName
		{
			get
			{
				return (string)GetValue(TargetNameProperty);
			}
			set
			{
				SetValue(TargetNameProperty, value);
			}
		}

		public event DelegateOnApplyEvent OnApply;

		public CurveStyleSettingWindow()
		{
			InitializeComponent();
		}

		public void SetTargetNames(List<string> names)
		{
			Dictionary<string, string> dictionary = new Dictionary<string, string>();
			dictionary.Add(Utility.GetMessage("All"), Utility.GetMessage("All"));
			foreach (string name in names)
			{
				dictionary.Add(name, name);
			}
			comboBoxSymbol2.ItemsSource = dictionary;
		}

		public bool IsAllTarget()
		{
			return TargetName.Equals(Utility.GetMessage("All"));
		}

		private void buttonOK_Click(object sender, RoutedEventArgs e)
		{
			if (this.OnApply != null)
			{
				this.OnApply(this, new EventArgs());
			}
		}

		private void buttonCancel_Click(object sender, RoutedEventArgs e)
		{
			Close();
		}

		private void Root_Loaded(object sender, RoutedEventArgs e)
		{
			if (comboBoxSymbol.ItemsSource == null)
			{
				rdTarget.Height = (ShowTargets ? new GridLength(40.0) : new GridLength(0.0));
				List<KeyValuePair> list = new List<KeyValuePair>();
				if (ShowTargets)
				{
					list.Add(new KeyValuePair
					{
						Key = ESeriesType.Null,
						Value = Utility.GetMessage("NA")
					});
				}
				list.Add(new KeyValuePair
				{
					Key = ESeriesType.None,
					Value = Utility.GetMessage("sign_None")
				});
				list.Add(new KeyValuePair
				{
					Key = ESeriesType.Circle,
					Value = Utility.GetMessage("sign_Circle")
				});
				list.Add(new KeyValuePair
				{
					Key = ESeriesType.Square,
					Value = Utility.GetMessage("sign_Square")
				});
				list.Add(new KeyValuePair
				{
					Key = ESeriesType.Triangle,
					Value = Utility.GetMessage("sign_Triangle")
				});
				list.Add(new KeyValuePair
				{
					Key = ESeriesType.X,
					Value = Utility.GetMessage("sign_X")
				});
				list.Add(new KeyValuePair
				{
					Key = ESeriesType.Dotted,
					Value = Utility.GetMessage("sign_dot")
				});
				list.Add(new KeyValuePair
				{
					Key = ESeriesType.Dashed,
					Value = Utility.GetMessage("sign_dash")
				});
				list.Add(new KeyValuePair
				{
					Key = ESeriesType.DashDot,
					Value = Utility.GetMessage("sign_dashdot")
				});
				comboBoxSymbol.ItemsSource = list;
			}
		}
	}
}
